package nl.boektrust.btsoep.wsimport.PersistentService;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 * <p>
 * Java class for person complex type.
 * 
 * <p>
 * The following schema fragment specifies the expected content contained within
 * this class.
 * 
 * <pre>
 * &lt;complexType name="person">
 *   &lt;complexContent>
 *     &lt;extension base="{http://server.btsoep.boektrust.nl/}btEntity">
 *       &lt;sequence>
 *         &lt;element name="biographical" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="birthPlace" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="birthYear" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         &lt;element name="booksContributedTo" type="{http://server.btsoep.boektrust.nl/}physicalBookManifestation" maxOccurs="unbounded" minOccurs="0"/>
 *         &lt;element name="deceasedPlace" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="deceasedYear" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         &lt;element name="identifier_dai" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="selected" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
 *       &lt;/sequence>
 *     &lt;/extension>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "person", propOrder = { "biographical", "birthPlace",
		"birthYear", "booksContributedTo", "deceasedPlace", "deceasedYear",
		"identifierDai", "selected" })
public class Person extends BtEntity {

	protected String biographical;
	protected String birthPlace;
	protected int birthYear;
	@XmlElement(nillable = true)
	protected List<PhysicalBookManifestation> booksContributedTo;
	protected String deceasedPlace;
	protected int deceasedYear;
	@XmlElement(name = "identifier_dai")
	protected String identifierDai;
	protected boolean selected;

	/**
	 * Gets the value of the biographical property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getBiographical() {
		return biographical;
	}

	/**
	 * Sets the value of the biographical property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setBiographical(String value) {
		this.biographical = value;
	}

	/**
	 * Gets the value of the birthPlace property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getBirthPlace() {
		return birthPlace;
	}

	/**
	 * Sets the value of the birthPlace property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setBirthPlace(String value) {
		this.birthPlace = value;
	}

	/**
	 * Gets the value of the birthYear property.
	 * 
	 */
	public int getBirthYear() {
		return birthYear;
	}

	/**
	 * Sets the value of the birthYear property.
	 * 
	 */
	public void setBirthYear(int value) {
		this.birthYear = value;
	}

	/**
	 * Gets the value of the booksContributedTo property.
	 * 
	 * <p>
	 * This accessor method returns a reference to the live list, not a
	 * snapshot. Therefore any modification you make to the returned list will
	 * be present inside the JAXB object. This is why there is not a
	 * <CODE>set</CODE> method for the booksContributedTo property.
	 * 
	 * <p>
	 * For example, to add a new item, do as follows:
	 * 
	 * <pre>
	 * getBooksContributedTo().add(newItem);
	 * </pre>
	 * 
	 * 
	 * <p>
	 * Objects of the following type(s) are allowed in the list
	 * {@link PhysicalBookManifestation }
	 * 
	 * 
	 */
	public List<PhysicalBookManifestation> getBooksContributedTo() {
		if (booksContributedTo == null) {
			booksContributedTo = new ArrayList<PhysicalBookManifestation>();
		}
		return this.booksContributedTo;
	}

	/**
	 * Gets the value of the deceasedPlace property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getDeceasedPlace() {
		return deceasedPlace;
	}

	/**
	 * Sets the value of the deceasedPlace property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setDeceasedPlace(String value) {
		this.deceasedPlace = value;
	}

	/**
	 * Gets the value of the deceasedYear property.
	 * 
	 */
	public int getDeceasedYear() {
		return deceasedYear;
	}

	/**
	 * Sets the value of the deceasedYear property.
	 * 
	 */
	public void setDeceasedYear(int value) {
		this.deceasedYear = value;
	}

	/**
	 * Gets the value of the identifierDai property.
	 * 
	 * @return possible object is {@link String }
	 * 
	 */
	public String getIdentifierDai() {
		return identifierDai;
	}

	/**
	 * Sets the value of the identifierDai property.
	 * 
	 * @param value
	 *            allowed object is {@link String }
	 * 
	 */
	public void setIdentifierDai(String value) {
		this.identifierDai = value;
	}

	/**
	 * Gets the value of the selected property.
	 * 
	 */
	public boolean isSelected() {
		return selected;
	}

	/**
	 * Sets the value of the selected property.
	 * 
	 */
	public void setSelected(boolean value) {
		this.selected = value;
	}

	@Override
	public String toString() {
		return "Person [biographical=" + biographical + ", birthPlace="
				+ birthPlace + ", birthYear=" + birthYear
				+ ", booksContributedTo=" + booksContributedTo
				+ ", deceasedPlace=" + deceasedPlace + ", deceasedYear="
				+ deceasedYear + ", identifierDai=" + identifierDai
				+ ", selected=" + selected + "]";
	}

	public void setParameter(String name, String value, String alt) {
		if ("selected".equals(name))
			try {
				selected = Boolean.parseBoolean(value);
			} catch (Exception e) {
				selected = Boolean.parseBoolean(alt);
			}
		else if ("deceasedYear".equals(name))
			try {
				deceasedYear = Integer.parseInt(value);
			} catch (Exception e) {
				deceasedYear = Integer.parseInt(alt);
			}
		else if ("birthYear".equals(name))
			try {
				birthYear = Integer.parseInt(value);
			} catch (Exception e) {
				birthYear = Integer.parseInt(alt);
			}
		else
			throw new IllegalAccessError("unknown key:" + name);
	}
}
